package com.example.jiaju.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

/**
 * @author starr
 */
public class MainFragmentStateAdapter extends FragmentStateAdapter {
    private List<Fragment> mFragmentList;
    public MainFragmentStateAdapter(@NonNull FragmentActivity fragmentActivity,List<Fragment> mFragmentList) {
        super(fragmentActivity);
        this.mFragmentList=mFragmentList;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return mFragmentList==null?null:mFragmentList.get(position);
    }

    @Override
    public int getItemCount() {
        return mFragmentList==null?0:mFragmentList.size();
    }
}
